#!/usr/bin/python

import sys
import math

# a, b, and c are lengths of the triangle sides.  d is the distance,
# or delta, from "straight ahead" vs the location of the car.  f is
# the camera's focal distance.  This code assumes that d has the same
# units as f, and I still need to figure out how to make that happen.
# But the math here is sound.
a = float(sys.argv[1])
b = float(sys.argv[2])
c = float(sys.argv[3])
d = float(sys.argv[4])
f = float(sys.argv[5])

A = math.acos((b ** 2 + c ** 2 - a ** 2) / (2 * b * c))
B = math.acos((c ** 2 + a ** 2 - b ** 2) / (2 * c * a))
C = math.pi - A - B
print A, B, C

theta = math.atan2(d, f)
alpha = math.pi - A - B
beta = B + theta
x = (c * math.sin(beta)) / math.sin(alpha)
print theta, alpha, beta, x
